<template>
  <aside class="simple-big-left">
    <!-- Header -->
    <div class="big-left__header">
      <div class="user-info">
        <div class="user-avatar">
          <div class="avatar-placeholder">客</div>
        </div>
        <div class="user-details">
          <h3 class="user-name">客服</h3>
          <span class="user-status user-status--online">
            在线
          </span>
        </div>
      </div>
      
      <div class="header-actions">
        <button class="action-button" title="切换主题">
          <span class="icon">🌙</span>
        </button>
        
        <button class="action-button" title="设置">
          <span class="icon">⚙️</span>
        </button>
      </div>
    </div>
    
    <!-- Navigation -->
    <nav class="big-left__navigation">
      <ul class="nav-list">
        <li
          v-for="item in navigation"
          :key="item.id"
          class="nav-item"
        >
          <button
            @click="handleNavigate(item.id)"
            :class="[
              'nav-button',
              { 'nav-button--active': activeItem === item.id }
            ]"
          >
            <span class="nav-icon">{{ getIcon(item.icon) }}</span>
            <span class="nav-label">{{ item.label }}</span>
            <span
              v-if="getNotificationCount(item.id) > 0"
              class="nav-badge"
            >
              {{ getNotificationCount(item.id) }}
            </span>
          </button>
        </li>
      </ul>
    </nav>
    
    <!-- Quick Actions -->
    <div class="big-left__quick-actions">
      <button class="quick-action-button quick-action-button--primary" title="新建聊天">
        <span class="icon">💬</span>
        <span class="label">新建聊天</span>
      </button>
      
      <button class="quick-action-button" title="搜索">
        <span class="icon">🔍</span>
        <span class="label">搜索</span>
      </button>
    </div>
    
    <!-- Status Indicator -->
    <div class="big-left__status">
      <div class="connection-status connection-status--connected">
        <span class="status-dot"></span>
        <span class="status-text">已连接</span>
      </div>
    </div>
    
    <!-- Footer -->
    <div class="big-left__footer">
      <div class="app-info">
        <span class="app-name">聊天系统</span>
        <span class="app-version">v1.0.0</span>
      </div>
      
      <button class="logout-button" title="退出登录">
        <span class="icon">🚪</span>
      </button>
    </div>
  </aside>
</template>

<script setup>
// Props
const props = defineProps({
  navigation: {
    type: Array,
    default: () => []
  },
  activeItem: {
    type: String,
    default: ''
  }
})

// Emits
const emit = defineEmits(['navigate'])

// Methods
const handleNavigate = (itemId) => {
  emit('navigate', itemId)
}

const getIcon = (iconName) => {
  const icons = {
    chat: '💬',
    contacts: '👥',
    settings: '⚙️',
    notifications: '🔔',
    help: '❓'
  }
  return icons[iconName] || '📄'
}

const getNotificationCount = (itemId) => {
  switch (itemId) {
    case 'chats':
      return 1
    case 'contacts':
      return 0
    case 'notifications':
      return 0
    default:
      return 0
  }
}
</script>

<style scoped>
.simple-big-left {
  width: 280px;
  height: 100vh;
  background: linear-gradient(180deg, #1890ff 0%, #096dd9 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

/* Header */
.big-left__header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.user-avatar {
  width: 48px;
  height: 48px;
}

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-size: 16px;
  font-weight: 600;
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px 0;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  font-size: 12px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #52c41a;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.action-button {
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.action-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.action-button .icon {
  font-size: 16px;
}

/* Navigation */
.big-left__navigation {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  margin-bottom: 4px;
}

.nav-button {
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: white;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  transition: background-color 0.2s;
  position: relative;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-button--active {
  background: rgba(255, 255, 255, 0.15);
  font-weight: 500;
}

.nav-button--active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: white;
}

.nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.nav-label {
  flex: 1;
}

.nav-badge {
  background: #ff4d4f;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Quick Actions */
.big-left__quick-actions {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-action-button {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  transition: all 0.2s;
}

.quick-action-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.quick-action-button--primary {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  font-weight: 500;
}

.quick-action-button .icon {
  font-size: 16px;
}

.quick-action-button .label {
  flex: 1;
}

/* Status */
.big-left__status {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  opacity: 0.8;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #52c41a;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Footer */
.big-left__footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-name {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.9;
}

.app-version {
  font-size: 10px;
  opacity: 0.6;
}

.logout-button {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.logout-button .icon {
  font-size: 14px;
}

/* Scrollbar */
.big-left__navigation::-webkit-scrollbar {
  width: 4px;
}

.big-left__navigation::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

.big-left__navigation::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.big-left__navigation::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}
</style>